/*
    openaltimeter -- an open-source altimeter for RC aircraft
    Copyright (C) 2010  Jan Steidl
    http://openaltimeter.org

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.openaltimeter.desktopapp.flightmodes;

import java.awt.Color;

public class FlightModeRecord implements Comparable<FlightModeRecord> 
{
	private Color color;
	private int microseconds;

	public FlightModeRecord(String code) 
	{
		String values[] = code.split(":");
		
		setColorRGB(Integer.valueOf(values[0]));
		setMicroseconds(Integer.valueOf(values[1]));
	}
	
	public FlightModeRecord(Color color, int microseconds) 
	{
		this.color = color;
		this.microseconds = microseconds;
	}
	
	public Color getColor() 
	{
		return color;
	}
	
	public void setColor(Color color) 
	{
		this.color = color;
	}
	
	public int getMicroseconds() 
	{
		return microseconds;
	}
	
	public void setMicroseconds(int microseconds) 
	{
		this.microseconds = microseconds;
	}
	
	public int getColorRGB() 
	{
		return this.color.getRGB();
	}
	
	public void setColorRGB(int rgb) 
	{
		this.color = new Color(rgb);
	}
	
	public String toString()
	{
		return getColorRGB() + ":" + getMicroseconds(); 
	}

	@Override
	public int compareTo(FlightModeRecord o) 
	{
		if (this.microseconds == o.getMicroseconds())
			return 0;
		else if (this.microseconds > o.getMicroseconds())
			return 1;
		else
			return -1;			
	}
}
